package com.kuun.config;

import com.mongodb.Mongo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

@Configuration
@EnableMongoRepositories(
        basePackages = {"com.kuun.mongo.repository"},
        mongoTemplateRef = "shopTemplate"
)
public class MongoPortfolioConfig {
	

 
    private String dataDatabase="mgtest";

    @Autowired
    Mongo mongo;

    @Bean(name = "shopTemplate")
    @Primary
    public MongoTemplate mongoTemplate() throws Exception {
        MongoTemplate mongoTemplate = new MongoTemplate(new SimpleMongoDbFactory(mongo, dataDatabase));
        return mongoTemplate;
    }
}
